import React, { Component } from 'react';
import { Link, hashHistory } from 'react-router';
import { inject, observer } from 'mobx-react';
import { Toast, ListView, Picker, Flex, InputItem, List } from 'antd-mobile';
import { createForm } from 'rc-form';
import Top from 'components/top';
import Ajax from 'lib/Ajax';
import ListMixin from 'mixin/list';

const pageName = 'zoneTeacher';
const Item = List.Item;
const Brief = Item.Brief;

@inject('appStore', 'languageStore')
@observer
class ModuleName extends ListMixin {
  constructor(props) {
    super(props);
    this.listApi = '/chat/getchatlinelist';
    this.state = Object.assign(this.state, {
      dataSource: []
    });
  }

  fetchList = (currentPage) => {
    const self = this;
    const { pageCount, isLoading } = self.state;
    if(isLoading){
      return
    }
    self.setState({
      isLoading: true
    });
    Ajax({
      url: this.listApi,
      data: {},
      success: function(result){
        self.setState({
          dataSource: result
        });
        self.setState({
          isLoading: false
        });
      },
      error: function(error){
        Toast.info(error||'请求失败');
        self.setState({
          isLoading: false
        });
      }
    });
  }

  render() {
    const pageData = this.props.languageStore.getPageData(pageName);

    const { imgBaseUrl, commonData } = this.props.appStore;

    return (
      <div className={pageName}>
        <Top
          title={pageData.title}
        />
        <div className={`${pageName}-con`}>
          <div className="interview-temp">
            <List>
              {
                this.state.dataSource.map(item=>{
                  return  <Item
                            key={item.chatLineId}
                            arrow="horizontal"
                            thumb={`${imgBaseUrl}${item.teacherCoverImg}`}
                            multipleLine
                            onClick={() => {hashHistory.push('/chat/' + item.chatLineId);}}
                          >
                            {item.teacherNickname}
                          </Item>
                })
              }
            </List>
          </div>
        </div>
      </div>
    )
  }
}


module.exports = ModuleName
